package com.fangwaii.core.datasource.unpooled;

import com.fangwaii.core.session.Configuration;
import com.fangwaii.core.datasource.ConnectionType;
import com.fangwaii.core.datasource.DataSource;
import com.fangwaii.core.datasource.DataSourceFactory;

/**
 * @author lxc18
 * @date 2024/12/3 16:39
 * @description UnpooledDataSourceFactory
 */
public class UnpooledDataSourceFactory implements DataSourceFactory {

    protected UnpooledDataSource dataSource;

    public UnpooledDataSourceFactory() {
        this.dataSource = new UnpooledDataSource();
    }

    @Override
    public void setProperties(Configuration configuration, String uri) {
        this.dataSource.setConfiguration(configuration);
        this.dataSource.setDataSourceType(ConnectionType.Dubbo);
        this.dataSource.setHttpStatement(configuration.getHttpStatement(uri));
    }

    @Override
    public DataSource getDataSource() {
        return dataSource;
    }

}